Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: list-view #2063

Merged
merged 42 commits into from
Dec 10, 2024
Merged

Conversation

RitvikSardana
Copy link
Member

@RitvikSardana RitvikSardana commented Nov 26, 2024

refactor List Views of pages:

  1. Agents
  2. Teams
  3. Customers
  4. Contacts

For all of the pages mentioned above, we were calling backend APIs for almost 25 times.
Screenshot 2024-12-07 at 9 00 25 PM

This PR refactors these list views, by creating a new component called "ListViewBuilder".

The component is very generic.

ListViewBuilder:

  1. Generates a list view with quick filters, filters, sort, and pagination.
  2. exposes a function called "reload"
  3. handles prefix for each column.
  4. handles fetch from fields.
  5. Provides a default slot which gives the list view data as slot props, to customise the list view even more.
  6. Provides 2 emits, row-click & empty-state-action.
image
  1. Accepts "option" prop which looks like
image
const options = computed(() => {
  return {
    doctype: "Contact",
    columnConfig: {
      full_name: {
        prefix: ({ row }) => {
          return h(Avatar, {
            shape: "circle",
            image: row.image,
            label: row.name,
            size: "sm",
          });
        },
      },
      mobile_no: {
        prefix: PhoneIcon,
      },
    },
    emptyState: {
      title: "No Contacts Found",
    },
  };
});

Result
image

@RitvikSardana RitvikSardana changed the title refactor:list-view refactor: list-view Nov 28, 2024
@RitvikSardana RitvikSardana marked this pull request as ready for review December 9, 2024 12:04
@RitvikSardana RitvikSardana merged commit e7e4009 into frappe:develop Dec 10, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant